﻿using System;
using System.Collections.Generic;
using Alimentador.Foods;

namespace Alimentador
{
    public class PersonPatient
    {
        /// <summary>
        /// 15
        /// </summary>
        public const int MINIMUM_AGE = 18;

        /// <summary>
        /// Male, Female
        /// </summary>
        public enum Gender
        {
            Male,
            Female
        }

        public string PatCreationDate { get; set; }
        public string PatName { get; set; }
        public int PatBirthYear { get; set; }
        public Gender PatGender { get; set; }
        public bool? PatPregnant { get; set; }
        public bool? PatFeeding { get; set; }
        public DefaultValues.PatStarRatingValues PatStarRating { get; set; }
        public double PatHeight { get; set; }
        public double PatWeight { get; set; }
        public double PatWaist { get; set; }
        public double PatIMC { get; set; }
        public DefaultValues.PCValues PatPC { get; set; }
        public string PatObs { get; set; }
        public List<PatientBiometricData> BiometricDataHistory = new List<PatientBiometricData>();

        /// <summary>
        /// Constuctor
        /// </summary>
        public PersonPatient()
        {
            PatCreationDate = "";
            PatName = "";
            PatBirthYear = 0;
            PatGender = Gender.Male;
            PatPregnant = false;
            PatFeeding = false;
            PatStarRating = DefaultValues.PatStarRatingValues.ActivityModerate;
            PatWeight = 0;
            PatHeight = 0;
            PatWaist = 0;
            PatIMC = 0;
            PatPC = DefaultValues.PCValues.None;
            PatObs = "";
        }

        internal void SaveBiometricData()
        {
            PatientBiometricData pbd = new PatientBiometricData();
            pbd.CreationDate = DateTime.Now;

            foreach (PatientBiometricData pbdInList in BiometricDataHistory)
            {
                if (pbdInList.CreationDate.DayOfYear == pbd.CreationDate.DayOfYear && pbdInList.CreationDate.Year == pbd.CreationDate.Year)
                {
                    pbdInList.CreationDate = pbd.CreationDate;
                    pbdInList.PatHeight = PatHeight;
                    pbdInList.PatWaist = PatWaist;
                    pbdInList.PatWeight = PatWeight;
                    return;
                }
            }

            pbd.PatHeight = PatHeight;
            pbd.PatWaist = PatWaist;
            pbd.PatWeight = PatWeight;

            BiometricDataHistory.Add(pbd);
        }
    }


    public class PatientBiometricData
    {
        public double PatHeight { get; set; }
        public double PatWeight { get; set; }
        public double PatWaist { get; set; }
        public DateTime CreationDate { get; set; }

        private string WeightStr = "Peso";
        private string WaistStr = "Cintura";

        public string GetWaistStr
        {
            get { return WaistStr; }
            set { WaistStr = value; }
        }

        public string GetDay
        {
            get
            {
                return CreationDate.ToString("yyyy-MM-dd");
            }
        }

        public string GetWeightStr
        {
            get { return WeightStr; }
            set { WeightStr = value; }
        }
        
        public PatientBiometricData()
        {

        }
    }
}

